<template>
  <Table
    :columns="columns"
    :data="data"
    border
    size="small"
    :tooltip-max-width="500"
  >
    <template slot-scope="{ row }" slot="type">
      {{ row.type === "testcase_result" ? "测试用例" : "扩展方法" }}
    </template>
    <template slot-scope="{ row }" slot="status">
      <Icon size="24" :color="statusColor[row.status]" type="ios-leaf" />
    </template>
  </Table>
</template>
<script>
export default {
  name: "testsuite2testcase-report",
  props: {
    data: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      statusColor: {
        PASS: "#19be6b",
        FAIL: "#ed4014",
      },
      columns: [
        {
          type: "index",
          width: 60,
          align: "center",
        },
        {
          title: "用例|方法名称",
          key: "testcase_name",
          width: 350,
          tooltip: true,
          align: "center",
        },
        {
          title: "用例类型",
          slot: "type",
          align: "center",
          width: 100,
        },
        {
          title: "接口",
          key: "api_name",
          width: 350,
          tooltip: true,
          align: "center",
        },
        {
          title: "请求URL",
          key: "url",
          width: 350,
          tooltip: true,
          align: "center",
        },
        {
          title: "请求方法",
          key: "method",
          align: "center",
          width: 100,
        },
        {
          title: "Headers参数",
          key: "headers",
          width: 350,
          tooltip: true,
          align: "center",
        },
        {
          title: "Body参数",
          key: "request_data",
          width: 350,
          tooltip: true,
          align: "center",
        },
        {
          title: "响应状态码",
          key: "actual_status_code",
          width: 120,
          align: "center",
        },
        {
          title: "响应时长(ms)",
          key: "elapsed_ms",
          width: 120,
          align: "center",
        },
        {
          title: "响应结果",
          key: "actual_response_data",
          minWidth: 350,
          align: "center",
          tooltip: true,
        },
        {
          title: "输出变量结果",
          key: "output_result",
          minWidth: 350,
          align: "center",
          tooltip: true,
        },
        {
          title: "失败原因",
          key: "failure_reason",
          minWidth: 350,
          align: "center",
          tooltip: true,
        },
        {
          title: "用例ID",
          key: "testcase_id",
          align: "center",
          width: 270,
          tooltip: true,
        },
        {
          title: "测试结果",
          slot: "status",
          align: "center",
          width: 85,
          fixed: "right",
        },
      ],
    };
  },
};
</script>
<style scoped>
</style>